/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sdd.facades.factories;

import com.sdd.entities.Comment;
import com.sdd.plains.CommentPlain;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;

/**
 *
 * @author Carlos
 */
@Stateless
@LocalBean
public class CommentFactoryFacadeBean {

    @EJB
    CustomerFactoryFacadeBean customerFactoryFacadeBean;
    @EJB
    ProductFactoryFacadeBean productFactoryFacadeBean;
        
    public CommentPlain createCommentPlain(Comment entity) {
        CommentPlain plain = new CommentPlain();
        plain.setId(entity.getId());
        plain.setCommentator(customerFactoryFacadeBean.createCustomerPlain(entity.getCommentator()));
        plain.setDateAdded(entity.getDateAdded());
        plain.setProduct(productFactoryFacadeBean.createProductPlain(entity.getProduct()));// <- No creo que sea necesario.
        plain.setText(entity.getText());
        return plain;
    }

    public List<CommentPlain> createCommentPlain(List<Comment> list) {
        List<CommentPlain> ret = new ArrayList<CommentPlain>();
        for (Comment comment : list) {
            ret.add(createCommentPlain(comment));
        }
        return ret;
    }

}
